<?php if (!defined('THINK_PATH')) exit();?><script type="text/javascript">
//选择事件
function S_NodeCheck(e, treeId, treeNode) {
    var zTree = $.fn.zTree.getZTreeObj(treeId),
        nodes = zTree.getCheckedNodes(true)
    var ids = '', names = ''
    
    for (var i = 0; i < nodes.length; i++) {
        ids   += ','+ nodes[i].id
        names += ','+ nodes[i].name
    }
    if (ids.length > 0) {
        ids = ids.substr(1), names = names.substr(1)
    }
    
    var $from = $('#'+ treeId).data('fromObj')
    $("#category_id").val(ids);
    if ($from && $from.length) $from.val(names)
}
//单击事件
function S_NodeClick(event, treeId, treeNode) {
    var zTree = $.fn.zTree.getZTreeObj(treeId)
    
    zTree.checkNode(treeNode, !treeNode.checked, true, true)
    
    event.preventDefault()
}
</script>
<div class="bjui-pageContent">
    <form action="<?php echo U(add);?>" class="pageForm" data-toggle="validate">
    <input type="hidden" name="closeCurrent" value="true"  />
    <input type="hidden" name="tabid" value="<?php echo (CONTROLLER_NAME); ?>"  />
        <table class="table table-condensed table-hover" width="100%">
            <tbody>
                <tr>
                    <td colspan="4">
                        <label for="title" class="control-label x85">文章标题：</label>
                         <input type="text" name="title" id="title" value="" data-rule="required" size="90">
                    </td>
                </tr>
                <tr>
                    <td colspan="4">
                        <label for="category_id" class="control-label x85">分类：</label>
                        <input type="hidden" name="category_id" id="category_id" value="" />
                        <input type="text" name="category_name" id="category" data-toggle="selectztree"  data-tree="#categorys" readonly>
                            <ul id="categorys" class="ztree hide" data-toggle="ztree" data-expand-all="true" data-check-enable="true" data-chk-style="radio" data-radio-type="all" data-on-check="S_NodeCheck" data-on-click="S_NodeClick">
                                <?php if(is_array($category)): $i = 0; $__LIST__ = $category;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><li data-id="<?php echo ($vo["id"]); ?>" data-pid="<?php echo ($vo["pid"]); ?>"><?php echo ($vo["name"]); ?></li><?php endforeach; endif; else: echo "" ;endif; ?>
                            </ul>
                    </td>
                </tr>
                <tr>
                    <td colspan="4">
                        <label for="keyword " class="control-label x85">关键词：</label>
                        <input type="text" name="keywords" id="keywords" value=""  size="90">
                    </td>
                </tr>
                <tr>
                    <td colspan="4">
                        <label for="description" class="control-label x85">描述：</label>
                        <input type="text" name="description" id="description" value="" size="90">
                    </td>
                </tr>
                <tr>
                    <td>
                        <script type="text/javascript">
    function upload_success(file, data) {
        var json = $.parseJSON(data)
        
        $(this).bjuiajax('ajaxDone', json)
        if (json[BJUI.keys.statusCode] == BJUI.statusCode.ok) {
            $('#add_pic').val(json.url)
            $('#add_span_pic').html('<img src="'+ json.url +'" width="100">')
        }
    }
</script>
<div style="display:inline-block; vertical-align:middle;">
    <div id="doc_pic_up" data-toggle="upload" data-uploader="<?php echo U(upload);?>" 
        data-file-size-limit="1024000000"
        data-file-type-exts="*.jpg;*.png;*.gif;*.mpg"
        data-multi="true"
        data-on-upload-success="upload_success"
        data-icon="cloud-upload"></div>
    <input type="hidden" name="pic" value="" id="add_pic">
</div>
<span id="add_span_pic"></span>
                    </td>
                </tr>
                <tr>
                    <td colspan="4">
                        <label for="content" class="control-label x85">内容编辑：</label>
                        <div style="display: inline-block; vertical-align: middle;">
                            <textarea name="content" id="content" class="content" style="width: 800px;" data-toggle="kindeditor" data-minheight="400">
                            </textarea>
                        </div>
                    </td>
                </tr>
            </tbody>
        </table>
    </form>
</div>
<div class="bjui-pageFooter">
    <ul>
        <li><button type="button" class="btn-close" data-icon="close">取消</button></li>
        <li><button type="submit" class="btn-default" data-icon="save">保存</button></li>
    </ul>
</div>